export let date = {
    namespaced: true,
    state: {
        date_data: [],
        date_flag: false,
        des_date_data: {},
        des_date_flag: false
    },
    actions: {
        getDateData(store, data = {}) {
            let url = "/day/history";
            axios.get(url).then(({
                data
            }) => {
                let option = [];
                for (const key in data.results) {
                    if (data.results.hasOwnProperty(key)) {
                        const element = data.results[key];
                        option.push({
                            value: key,
                            label: element
                        });
                    }
                }
                store.commit("setDateData", option)
            });
        },
        getDesDateData(store, data = {}) {
            let url = "/history/content/day/" + data.year + "/" + data.month + "/" + data.day;
            axios.get(url).then(({
                data
            }) => {
                store.commit("setDesDateData", data.results[0])
            });
        }
    },
    mutations: {
        setDateData(state, data) {
            state.date_data = data;
            state.date_flag = true;
        },
        setDesDateData(state, data) {
            state.des_date_data = data;
            state.des_date_flag = true;
        }
    }
}